Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: break between non-block if/else statements #633

Conversation

jtkiesel
Copy link
Contributor

@jtkiesel jtkiesel commented Jan 9, 2024

What changed with this PR:

Non-block if/else statements are now kept on their own lines, like Prettier JavaScript does. This aligns Prettier Java with the Checkstyle config that it provides.

Example

Input

class Example {

  void example() {
    if (test); else {
      System.out.println("one");
    }

    if (test); else;

    if (this instanceof Circle) return "Circle: " + area(); else if (
      this instanceof Rectangle
    ) return "Rectangle: " + area(); else if (
      this instanceof RightTriangle
    ) return "Triangle: " + area();
  }
}

Output

class Example {

  void example() {
    if (test);
    else {
      System.out.println("one");
    }

    if (test);
    else;

    if (this instanceof Circle) return "Circle: " + area();
    else if (this instanceof Rectangle) return "Rectangle: " + area();
    else if (this instanceof RightTriangle) return "Triangle: " + area();
  }
}

Relative issues or prs:

Closes #631

@clementdessoude clementdessoude merged commit 983a09d into jhipster:main Jan 14, 2024
6 checks passed
@jtkiesel jtkiesel deleted the fix/break-between-non-block-if-else-statements branch January 15, 2024 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

checkstyle inconsistent with prettier
2 participants